package o;

import android.graphics.Typeface;
import android.os.ParcelFileDescriptor;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import java.io.File;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

@RequiresApi(21)
@RestrictTo({d.ॱ})
class gc extends gb {
    private static Class ˊ;
    private static Method ˋ;
    private static Method ˎ;
    private static Constructor ˏ;
    private static boolean ॱ = false;

    public android.graphics.Typeface ॱ(android.content.Context r10, androidx.core.content.res.FontResourcesParserCompat.e r11, android.content.res.Resources r12, int r13) {
        /* JADX: method processing error */
/*
Error: java.lang.NullPointerException
	at jadx.core.dex.visitors.ssa.SSATransform.placePhi(SSATransform.java:82)
	at jadx.core.dex.visitors.ssa.SSATransform.process(SSATransform.java:50)
	at jadx.core.dex.visitors.ssa.SSATransform.visit(SSATransform.java:42)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:31)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:17)
	at jadx.core.ProcessClass.process(ProcessClass.java:37)
	at jadx.api.JadxDecompiler.processClass(JadxDecompiler.java:306)
	at jadx.api.JavaClass.decompile(JavaClass.java:62)
*/
        /*
        r9 = this;
        r0 = 0;
        r2 = ˎ();
        r3 = r11.ˊ();
        r4 = r3.length;
        r1 = 0;
    L_0x000b:
        if (r1 >= r4) goto L_0x004a;
    L_0x000d:
        r5 = r3[r1];
        r6 = o.gh.ˎ(r10);
        if (r6 != 0) goto L_0x0016;
    L_0x0015:
        return r0;
    L_0x0016:
        r7 = r5.ʼ();	 Catch:{ RuntimeException -> 0x0040, all -> 0x0045 }
        r7 = o.gh.ˎ(r6, r12, r7);	 Catch:{ RuntimeException -> 0x0040, all -> 0x0045 }
        if (r7 != 0) goto L_0x0024;
    L_0x0020:
        r6.delete();
        goto L_0x0015;
    L_0x0024:
        r7 = r6.getPath();	 Catch:{ RuntimeException -> 0x0040, all -> 0x0045 }
        r8 = r5.ॱ();	 Catch:{ RuntimeException -> 0x0040, all -> 0x0045 }
        r5 = r5.ˏ();	 Catch:{ RuntimeException -> 0x0040, all -> 0x0045 }
        r5 = ˋ(r2, r7, r8, r5);	 Catch:{ RuntimeException -> 0x0040, all -> 0x0045 }
        if (r5 != 0) goto L_0x003a;
    L_0x0036:
        r6.delete();
        goto L_0x0015;
    L_0x003a:
        r6.delete();
        r1 = r1 + 1;
        goto L_0x000b;
    L_0x0040:
        r1 = move-exception;
        r6.delete();
        goto L_0x0015;
    L_0x0045:
        r0 = move-exception;
        r6.delete();
        throw r0;
    L_0x004a:
        r0 = ˊ(r2);
        goto L_0x0015;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.gc.ॱ(android.content.Context, androidx.core.content.res.FontResourcesParserCompat$e, android.content.res.Resources, int):android.graphics.Typeface");
    }

    gc() {
    }

    private static void ˋ() {
        Method method;
        Constructor constructor;
        Class cls;
        Throwable e;
        Method method2 = null;
        if (!ॱ) {
            ॱ = true;
            try {
                Class cls2 = Class.forName("android.graphics.FontFamily");
                Constructor constructor2 = cls2.getConstructor(new Class[0]);
                Method method3 = cls2.getMethod("addFontWeightStyle", new Class[]{String.class, Integer.TYPE, Boolean.TYPE});
                method = Typeface.class.getMethod("createFromFamiliesWithDefault", new Class[]{Array.newInstance(cls2, 1).getClass()});
                method2 = method3;
                constructor = constructor2;
                cls = cls2;
            } catch (ClassNotFoundException e2) {
                e = e2;
                Log.e("TypefaceCompatApi21Impl", e.getClass().getName(), e);
                method = null;
                constructor = null;
                cls = null;
                ˏ = constructor;
                ˊ = cls;
                ˋ = method2;
                ˎ = method;
            } catch (NoSuchMethodException e3) {
                e = e3;
                Log.e("TypefaceCompatApi21Impl", e.getClass().getName(), e);
                method = null;
                constructor = null;
                cls = null;
                ˏ = constructor;
                ˊ = cls;
                ˋ = method2;
                ˎ = method;
            }
            ˏ = constructor;
            ˊ = cls;
            ˋ = method2;
            ˎ = method;
        }
    }

    private File ˏ(@NonNull ParcelFileDescriptor parcelFileDescriptor) {
        try {
            String readlink = Os.readlink("/proc/self/fd/" + parcelFileDescriptor.getFd());
            if (OsConstants.S_ISREG(Os.stat(readlink).st_mode)) {
                return new File(readlink);
            }
            return null;
        } catch (ErrnoException e) {
            return null;
        }
    }

    private static Object ˎ() {
        Throwable e;
        ˋ();
        try {
            return ˏ.newInstance(new Object[0]);
        } catch (IllegalAccessException e2) {
            e = e2;
            throw new RuntimeException(e);
        } catch (InstantiationException e3) {
            e = e3;
            throw new RuntimeException(e);
        } catch (InvocationTargetException e4) {
            e = e4;
            throw new RuntimeException(e);
        }
    }

    private static Typeface ˊ(Object obj) {
        Throwable e;
        ˋ();
        try {
            Array.set(Array.newInstance(ˊ, 1), 0, obj);
            return (Typeface) ˎ.invoke(null, new Object[]{r0});
        } catch (IllegalAccessException e2) {
            e = e2;
            throw new RuntimeException(e);
        } catch (InvocationTargetException e3) {
            e = e3;
            throw new RuntimeException(e);
        }
    }

    private static boolean ˋ(Object obj, String str, int i, boolean z) {
        Throwable e;
        ˋ();
        try {
            return ((Boolean) ˋ.invoke(obj, new Object[]{str, Integer.valueOf(i), Boolean.valueOf(z)})).booleanValue();
        } catch (IllegalAccessException e2) {
            e = e2;
            throw new RuntimeException(e);
        } catch (InvocationTargetException e3) {
            e = e3;
            throw new RuntimeException(e);
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public android.graphics.Typeface ˋ(android.content.Context r8, android.os.CancellationSignal r9, @androidx.annotation.NonNull androidx.core.provider.FontsContractCompat.b[] r10, int r11) {
        /*
        r7 = this;
        r0 = 0;
        r1 = r10.length;
        r2 = 1;
        if (r1 >= r2) goto L_0x0006;
    L_0x0005:
        return r0;
    L_0x0006:
        r1 = r7.ˎ(r10, r11);
        r2 = r8.getContentResolver();
        r1 = r1.ˊ();	 Catch:{ IOException -> 0x0028 }
        r3 = "r";
        r3 = r2.openFileDescriptor(r1, r3, r9);	 Catch:{ IOException -> 0x0028 }
        r2 = 0;
        if (r3 != 0) goto L_0x002e;
    L_0x001b:
        if (r3 == 0) goto L_0x0005;
    L_0x001d:
        if (r0 == 0) goto L_0x002a;
    L_0x001f:
        r3.close();	 Catch:{ Throwable -> 0x0023 }
        goto L_0x0005;
    L_0x0023:
        r1 = move-exception;
        r2.addSuppressed(r1);	 Catch:{ IOException -> 0x0028 }
        goto L_0x0005;
    L_0x0028:
        r1 = move-exception;
        goto L_0x0005;
    L_0x002a:
        r3.close();	 Catch:{ IOException -> 0x0028 }
        goto L_0x0005;
    L_0x002e:
        r1 = r7.ˏ(r3);	 Catch:{ Throwable -> 0x005d, all -> 0x006f }
        if (r1 == 0) goto L_0x003a;
    L_0x0034:
        r4 = r1.canRead();	 Catch:{ Throwable -> 0x005d, all -> 0x006f }
        if (r4 != 0) goto L_0x008f;
    L_0x003a:
        r4 = new java.io.FileInputStream;	 Catch:{ Throwable -> 0x005d, all -> 0x006f }
        r1 = r3.getFileDescriptor();	 Catch:{ Throwable -> 0x005d, all -> 0x006f }
        r4.<init>(r1);	 Catch:{ Throwable -> 0x005d, all -> 0x006f }
        r5 = 0;
        r1 = super.ˊ(r8, r4);	 Catch:{ Throwable -> 0x007b, all -> 0x00af }
        if (r4 == 0) goto L_0x004f;
    L_0x004a:
        if (r0 == 0) goto L_0x006b;
    L_0x004c:
        r4.close();	 Catch:{ Throwable -> 0x0058, all -> 0x006f }
    L_0x004f:
        if (r3 == 0) goto L_0x0056;
    L_0x0051:
        if (r0 == 0) goto L_0x0077;
    L_0x0053:
        r3.close();	 Catch:{ Throwable -> 0x0072 }
    L_0x0056:
        r0 = r1;
        goto L_0x0005;
    L_0x0058:
        r4 = move-exception;
        r5.addSuppressed(r4);	 Catch:{ Throwable -> 0x005d, all -> 0x006f }
        goto L_0x004f;
    L_0x005d:
        r1 = move-exception;
        throw r1;	 Catch:{ all -> 0x005f }
    L_0x005f:
        r2 = move-exception;
        r6 = r2;
        r2 = r1;
        r1 = r6;
    L_0x0063:
        if (r3 == 0) goto L_0x006a;
    L_0x0065:
        if (r2 == 0) goto L_0x00ab;
    L_0x0067:
        r3.close();	 Catch:{ Throwable -> 0x00a6 }
    L_0x006a:
        throw r1;	 Catch:{ IOException -> 0x0028 }
    L_0x006b:
        r4.close();	 Catch:{ Throwable -> 0x005d, all -> 0x006f }
        goto L_0x004f;
    L_0x006f:
        r1 = move-exception;
        r2 = r0;
        goto L_0x0063;
    L_0x0072:
        r3 = move-exception;
        r2.addSuppressed(r3);	 Catch:{ IOException -> 0x0028 }
        goto L_0x0056;
    L_0x0077:
        r3.close();	 Catch:{ IOException -> 0x0028 }
        goto L_0x0056;
    L_0x007b:
        r2 = move-exception;
        throw r2;	 Catch:{ all -> 0x007d }
    L_0x007d:
        r1 = move-exception;
    L_0x007e:
        if (r4 == 0) goto L_0x0085;
    L_0x0080:
        if (r2 == 0) goto L_0x008b;
    L_0x0082:
        r4.close();	 Catch:{ Throwable -> 0x0086, all -> 0x006f }
    L_0x0085:
        throw r1;	 Catch:{ Throwable -> 0x005d, all -> 0x006f }
    L_0x0086:
        r4 = move-exception;
        r2.addSuppressed(r4);	 Catch:{ Throwable -> 0x005d, all -> 0x006f }
        goto L_0x0085;
    L_0x008b:
        r4.close();	 Catch:{ Throwable -> 0x005d, all -> 0x006f }
        goto L_0x0085;
    L_0x008f:
        r1 = android.graphics.Typeface.createFromFile(r1);	 Catch:{ Throwable -> 0x005d, all -> 0x006f }
        if (r3 == 0) goto L_0x009a;
    L_0x0095:
        if (r0 == 0) goto L_0x00a2;
    L_0x0097:
        r3.close();	 Catch:{ Throwable -> 0x009d }
    L_0x009a:
        r0 = r1;
        goto L_0x0005;
    L_0x009d:
        r3 = move-exception;
        r2.addSuppressed(r3);	 Catch:{ IOException -> 0x0028 }
        goto L_0x009a;
    L_0x00a2:
        r3.close();	 Catch:{ IOException -> 0x0028 }
        goto L_0x009a;
    L_0x00a6:
        r3 = move-exception;
        r2.addSuppressed(r3);	 Catch:{ IOException -> 0x0028 }
        goto L_0x006a;
    L_0x00ab:
        r3.close();	 Catch:{ IOException -> 0x0028 }
        goto L_0x006a;
    L_0x00af:
        r1 = move-exception;
        r2 = r0;
        goto L_0x007e;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.gc.ˋ(android.content.Context, android.os.CancellationSignal, androidx.core.provider.FontsContractCompat$b[], int):android.graphics.Typeface");
    }
}
